#include "xlcomm/net/tcp_server.h"
using namespace xlcomm;

void OnMessage(const net::TcpConnectionPtr& conn, net::Buffer* buff,
               Timestamp recv_time) {
  LOG_INFO << "read " << buff->ReadableBytes() << " bytes from "
           << conn->peer_addr().ToIpPort() << " at "
           << DateTime::Format(recv_time);
  conn->Send(buff);
}

int main() {
  net::EventLoop loop;
  net::TcpServer server(&loop, net::InetAddress(5555), "my_server");
  server.set_message_callback(OnMessage);
  server.Start(0);
  loop.Loop();
  return 0;
}